require(['./config'],()=>{
    require(['swiper','template','header','footer','jquery'],(Swiper,template)=>{
        class Index{
            constructor(){
                this.getbanner()
                this.getlist()
            }
            getbanner(){   
                var mySwiper = new Swiper ('.swiper-container', {
                    direction: 'horizontal', // 垂直切换选项
                    loop: true, // 循环模式选项
                    autoplay:true,

                    // 如果需要分页器
                    pagination: {
                    el: '.swiper-pagination',
                    clickable :true,
                    },
                    
                    // 如果需要前进后退按钮
                    navigation: {
                    nextEl: '.swiper-button-next',
                    prevEl: '.swiper-button-prev',
                    },
                })
                mySwiper.el.onmouseover = function(){
                    mySwiper.autoplay.stop();
                  }
                  
                  //鼠标离开开始自动切换
                  mySwiper.el.onmouseout = function(){
                    mySwiper.autoplay.start();
                  }   
            }
            getlist(){
                $.get('http://www.xiongmaoyouxuan.com/api/search?word=%E7%94%9F%E6%97%A5%E8%9B%8B%E7%B3%95&start=0&sort=0&couponOnly=NaN&minPrice=0&maxPrice=99999',(resp)=>{
                    if(resp.code === 200){
                        const{ list } = resp.data
                        $('.cake-img-list').html(
                            template('cake-img-listTemplate',{list})
                        )
                    }
                })
            }
        }
         new Index()
    })
})